Skip to content

Conversation

@pmenzel
Copy link
Contributor

@pmenzel pmenzel commented Jul 15, 2026

No description provided.

…rom 1 s to 0.1 s

So the 7s splits into two very different halves:

┌─────────────────────────────────────────────┬──────────┬────────────────────────────────────────────────────────────────────────┐
│                   Segment                   │ Duration │                                 Cause                                  │
├─────────────────────────────────────────────┼──────────┼────────────────────────────────────────────────────────────────────────┤
│ service start → carrier up (2.962 → 6.694)  │ ~3.73s   │ r8169 gigabit link negotiation. Ping cannot succeed here — no carrier. │
├─────────────────────────────────────────────┼──────────┼────────────────────────────────────────────────────────────────────────┤
│ carrier up → ping succeeds (6.694 → 10.028) │ ~3.33s   │ your loop's granularity + DNS/ARP on the first real attempt            │
└─────────────────────────────────────────────┴──────────┴────────────────────────────────────────────────────────────────────────┘

The second half is the surprising one, and it's entirely self-inflicted by the loop shape:

while ! ping -c 1 -w 1 rick.molgen.mpg.de; do sleep 1 ; done

Two costs stack up after the link is already up at 6.694s:

1. Coarse polling. Each miss is ping -w 1 (up to 1s) plus sleep 1 — up to ~2s of dead time per iteration. When carrier came up at 6.694s the loop was almost certainly mid-sleep 1, so you eat the rest of a
sleep, then a failed attempt, then another sleep before the winning ping. That alone explains ~2–3s.
2. DNS every iteration. You ping a hostname, so each attempt resolves rick.molgen.mpg.de first. Early in boot the resolver can stall/retry, and it's on the hot path for every loop pass.

So ~3.7s is a hardware/switch floor (gigabit autoneg — Link Down 3.98s → Up 6.69s), but ~3s is recoverable in software.

Concrete fix

Tighten the loop and take DNS out of the path:

ExecStart=/bin/bash -c 'until ping -c1 -W1 <rick-ip> >/dev/null 2>&1; do sleep 0.2; done'
TimeoutStartSec=30

- Drop the sleep 1 → sleep 0.2: post-carrier dead time falls from up to ~2s to ~0.2s.
- -W1 is the per-packet wait (fast fail while carrier is down returns immediately as "Network unreachable"), and the small sleep keeps it from busy-spinning during those ~3.7s.
- Ping the IP (or put rick in /etc/hosts) to remove DNS retry variance.
- TimeoutStartSec=30 so a genuinely-broken network fails the boot instead of hanging forever — your current infinite while has no guard.

Expected effect: cuts the second half from ~3.3s to well under 1s, i.e. +7.066s → roughly ~4s (the carrier floor plus one clean ping).
@donald
Copy link
Collaborator

donald commented Jul 15, 2026

The change is okay. The commit message contains some nonsense. We do want to check DNS, we already have a timeout in the service file. I'm not sure about the -w .vs. -W part. Manpage is not really clear.

Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants